package com.yy.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Author young
 * Date 2023/1/5 22:18
 * Description: 读取配置中心的配置信息
 */
@RestController
@RequestMapping("read")
//自动刷新配置
@RefreshScope 
public class ReadMsgController {
    @Value("${spring.datasource.username}")
    private String username;
    @Value("${spring.datasource.password}")
    private String password;
    
    @GetMapping("msg")
    public String msg() {
        return "读取的信息为:"+username+"\n\t"+password;
    }
}
